{% extends 'base_authed.html' %}

{% block title %}收件箱{% endblock %}
{% block js %}
<script type="text/javascript">
	function deleteMessage(msgId){
		if(confirm('您确定要删除该消息吗？')){
			new Request({url: '/inbox/delmessage/' + msgId + '/', onSuccess: function(responseText){
				if(responseText){
					$(msgId.toString()).destroy();
				}
				else{
					alert('删除消息失败！');
				}
			}}).send();
		}
	}
</script>
{% endblock %}

{% block content %}
<div>
	<div>
		<span style="border:solid 1px #333">
			<a href="/inbox/" style="background:#aaa">收件箱</a> | <a href="/outbox/">发件箱</a>
		</span>
		<span style="border:solid 1px #333;margin-left:800px"><a href="/inbox/sendmessage/">写消息</a></span>
		<div style="border:solid 1px #333">
			<input type="text" value="搜索收件箱" />
		</div>
	</div>
	<table cellpadding=0 cellspacing=0 border=0>
		{% for message in messages %}
		<tr id="{{ message.id }}" style="background:{% cycle #fff,#eee %}">
			<td style="width:15px">
			{% if not message.is_read %}
				<img src="/site_media/img/inbox/new_message.gif" />
			{% endif %}
			</td>
			<td style="width:200px">
				发件人：{{ message.sender.get_full_name }}
				<br />
				{{ message.post_time|date:"Y-m-d H:i" }}
			</td>
			<td>
				<a href="/inbox/readmessage/{{ message.id }}/">{{ message.title }}</a>
				<br />
				<span style="color:#777">{{ message.content }}</span>
			</td>
			<td style="width:30px;text-align:center">
				<a href="javascript:deleteMessage({{ message.id }})">X</a>
			</td>
		</tr>
		{% endfor %}
	</table>
</div>
{% endblock %}